<?php
/**
 * Truncate a block of text to a number of words. This takes html into account.
 *
 * @package     Visi
 * @subpackage  View Helpers
 * @author      Luke Visinoni <luke.visinoni@gmail.com>
 * @copyright   (c) 2011 Coalition Technologies <joel@coalitiontechnologies.com>
 * @version     $Id$
 * @todo        This is just a placeholder so I could put in my views so that
 *              once it's complete, I don't have to then go back and find all
 *              the places I want to use it. So finish this.
 */
class Visi_View_Helper_TruncateHtmlWords extends Zend_View_Helper_Abstract {

    public function truncateHtmlWords($text, $num, $after = '') {
    
        $words = explode(" ", $text);
        $ret = implode(" ", array_slice($words, 0, $num));
        if (count($words) > $num) {
            $ret .= $after;
        }
        return $ret;
    
    }

}
